<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    let arr = [
        {
            id: 1,
            name: '张三',
            age: 21,
            workInfo: {
                addr: '北京市XXXXX',
                salary: 10000,
                year: 2
            }
        },
        {
            id: 2,
            name: '李四',
            age: 31,
            workInfo: {
                addr: '上海市XXXXX',
                salary: 200000,
                year: 3
            }
        }
    ]
    let personObj = {
        id: 5,
        name: '赵六',
        age: 31,
        workInfo: {
            addr: '青岛市XXXXX',
            salary: 50000,
            year: 1
        }
    }
    arr.push(personObj)
    // console.log('arr:',arr)

    // arr.splice(0, 1)
    // const idx = arr.findIndex(item => item.id === 1)
    const idx = arr.findIndex(item => item.name === '赵六')
    // console.log('arr:', arr)
    // console.log('idx:', idx)
    arr.splice(idx,1)
    // findIndex splice
    console.log('arr:', arr)
</script>
</body>
</html>
